package jmcnet.libcommun.jmcnetds.flex
{
	import com.adobe.cairngorm.control.CairngormEvent;

	public class BaseEvent extends CairngormEvent
	{
		private var _callback_onOK:Function = null;
		private var _callback_onError:Function = null;
		
		public function BaseEvent(type:String,
			callback_onOK:Function=null,
			callback_onError:Function=null,
			bubbles:Boolean=false, cancelable:Boolean=false)	{
			super(type, bubbles, cancelable);
			this._callback_onOK = callback_onOK;
			this._callback_onError = callback_onError;
		}
		
		public function get callback_onOK():Function { return _callback_onOK;};
		public function get callback_onError():Function { return _callback_onError;};
		
		public function set callback_onOK(callback_onOK:Function):void { _callback_onOK = callback_onOK;};
		public function set callback_onError(callback_onError:Function):void { _callback_onError = callback_onError;};
		
		public function callback(ok:Boolean, data:Object):void {
			if (ok && _callback_onOK != null) {
				_callback_onOK(data);
			}
			
			if (!ok && _callback_onError != null) {
				_callback_onError(data);
			}
		}
	}
}